<?PHP
/*
1. dpInitPage
    a. If $Context, ok so exit.
    b. new Context
    c. session_start
        ( maybe we have cookie info from the request.
          maybe it has a session id.
          maybe it is a valid database key to a session record.
          maybe we will get a $_SESSION array.
          maybe containing username.
          maybe not anonymous
          maybe the user code can be found in the users table.
          If all that, log 'em in. )
            ( To log out, prevent the above
              by removing database record. )
    d. $Context->InitUser()

2. $Context->InitUser
    a. tries for $_SESSION('username').
    b. is one? LoginSessionUser.
    c. not? LoginUser.

3a. LoginSessionUser
    a. $User = new User($username)

3b. LoginUser
    a. $_POST for username and passwordmd5?
        a1. ? IsBbLogin(username, md5(pwd)
            a1a. $_SESSION <= $username
            a1b. LoginSessionUser

1. user submits id and password (in any form, when prompted in quickmenu.

2. next form (with dpheader) tries for session, which fails.

This should be the first code executed for any primary form.
It:     1. Sets manifest constants.
		2. Creates $Context.
		3. Starts a session.
*/

error_reporting(E_ALL);
require_once 'define.inc';
// $is_require_login determines whether the user must log in to proceed.
function dpInitPage($page_code = null)
{
	// global $DpDb;
	global $Context;

	// if we have context, we've been here before.
	if(isset($Context))
        return;

	require_once "ContextClass.inc";
    $Context = new Context($page_code) ;

	// Go for a session. If one is recoverable, pick it up and proceed.
	// Else prompt for login.
	require_once 'dpsession.inc';
	session_start();

    $Context->InitUser() ;
}
?>
